import request from 'umi-request';

export async function queryArchiveStaffList(params = {}) {
  return request('/hr-ssc/api/api-admin/newEmployees/getEmployeeArchiveServivePage', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      name:params.name,
      orgname:params.orgname,
      unitname:params.unitname,
      jobname:params.jobname,
      socialTrainee:parseInt(params.socialTrainee)
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function queryRule(params = {}) {
  return request('/hr-ssc/api/api-admin/newEmployees/list', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      status:params.status,
      name:params.name,
      orgname:params.orgname,
      unitname:params.unitname,
      jobname:params.jobname,
      isEntryStatus:1,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getAccountOpenList(params = {},status) {
  return request('/hr-ssc/api/api-admin/employeeChange/getList', {
    method: 'post',
    data: {
      status,
      pageNum: params.current,
      ...params
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function confirmChange(id){
  return request('/hr-ssc/api/api-admin/employeeChange/confirmChange', {
    method: 'post',
    data: {id},
    requestType: 'form'
  }).then((res) => {
    return res
  })
}

export async function queryArchiveList(params) {
  return request('/hr-ssc/api/api-admin/newEmployees/getEmployeeInfoPage', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      ...params
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function saveAndUpdateEmployeeInfoList(codes){
  return request('/hr-ssc/api/api-admin/neusoft/saveAndUpdateEmployeeInfoList', {
    method: 'get',
    params: {codeStr:codes},
  }).then((res) => {
    return res
  })
}

export async function loginMember(oid) {
  return request('/hr-ssc/api/api-admin/employeeBasis/loginMember', {
    method: 'post',
    data: {oid:oid},
  }).then((res) => {
    return res;
  })
}
